{include file="public/header" /}

<div class="page">
	<div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>项目定制</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
        <form id="brand_form" method="post" name="form1" enctype="multipart/form-data">
            <input type="hidden" name="project_id" value="{$brand_array.project_id}" />
            <table class="ds-default-table">
                <tbody>
                 <!-- <tr class="noborder">
                  <td class="required"><label class="validation">商品绑定:</label></td>
                   <td><a href="javascript:void(0);" onclick="
                   edit_band_goods({$brand_array['project_id']});" class="dsui-btn-edit"><i class="iconfont"></i>选择需要绑定的商品</a></td>
                </tr> -->
                <tr class="noborder">
                    <td class="required w120"><label class="validation">项目定制标题:</label></td>
                    <td class="vatop rowform"><input type="text" value="{$brand_array.project_title}" name="project_title" id="project_title" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                <td class="required"> 图片:</td>
                <td class="vatop rowform">
                   <img width="300px" height="200px" src="{$Think.UPLOAD_SITE_URL}/home/membertag/{$brand_array.project_images}" />
                    <span class="type-file-box">
                        <input name="project_images" type="file" class="type-file-file" id="project_images" size="30" hidefocus="true">
                    </span>
                </td>
              </tr>
                 <tr class="noborder"> 
                    <td class="required">项目定制描述</td>
                    {:build_editor(['name'=>'article_content'])}
                    <td class="vatop rowform" colspan="2"><textarea name="project_describe" id="article_content" style="width:100%;height:300px;">{$brand_array.project_describe}</textarea></td>
                </tr>
                <tr class="noborder">
                    <td class="required">上下架: </td>
                    <td class="vatop rowform onoff"><label for="brand_recommend1" class="cb-enable {if $brand_array.status == '1'}selected{/if}" title="{$Think.lang.ds_yes}"><span>上架</span></label>
                        <label for="brand_recommend0" class="cb-disable {if $brand_array.status == '0'}selected{/if}" title="{$Think.lang.ds_no}"><span>下架</span></label>
                        <input id="brand_recommend1" name="status" {if $brand_array.status == '1'}checked="checked"{/if} value="1" type="radio">
                        <input id="brand_recommend0" name="status" {if $brand_array.status == '0'}checked="checked"{/if} value="0" type="radio"></td>
                </tr>
 
                <tr>
                    
                </tr>
                </tbody>
                <tfoot>
                <tr class="tfoot" style="text-align:center;">
                    <td colspan="15" ><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
                </tr>
                </tfoot>
            </table>
        </form>
    </div>
<script src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js"></script>
<script>
    function call_back(picname){
        $('#brand_pic').val(picname);
        $('#view_img').attr('src','{$Think.UPLOAD_SITE_URL}/{$Think.ATTACH_BRAND}/'+picname);
    }
    //按钮先执行验证再提交表单
    $(function(){
        // 编辑分类时清除分类信息
        $('.edit_gcategory').click(function(){
            $('input[name="class_id"]').val('');
            $('input[name="brand_class"]').val('');
        });

        var textButton1="<input type='text' name='textfield' id='textfield1' class='type-file-text' /><input type='button' name='button' id='button1' value='' class='type-file-button' />"
        $(textButton1).insertBefore("#project_images");
        $("#project_images").change(function(){$("#textfield1").val($("#project_images").val());});
        jQuery.validator.addMethod("initial", function(value, element) {
            return /^[A-Za-z0-9]$/i.test(value);
        }, "");
        $("#brand_form").validate({
            errorPlacement: function(error, element){
                error.appendTo(element.parent().parent().find('td:last'));
            },
            rules : {
                brand_name : {
                    required : true,
                    remote   : {
                        url :"{:url('Brand/ajax','branch=check_brand_name')}",
                        type:'get',
                        data:{
                            brand_name : function(){
                                return $('#brand_name').val();
                            },
                            id  : '{$brand_array.project_id}'
                        }
                    }
                },
                brand_initial : {
                    initial  : true
                },
                brand_sort : {
                    number   : true,
                    range : [0,255]
                }
            },
            messages : {
                brand_name : {
                    required : '{$Think.lang.brand_add_name_null}',
                    remote   : '{$Think.lang.brand_add_name_exists}'
                },
                brand_initial : {
                    initial : '{$Think.lang.brand_add_initial}'
                },
                brand_sort  : {
                    number   : '{$Think.lang.brand_add_sort_int}',
                    range : '{$Think.lang.class_sort_explain}'
                }
            }
        });
    });

    gcategoryInit('gcategory');

    function edit_band_goods(ids_str) {
    	
      _uri = ADMINSITEURL+"/Goodproject/edit_band_goods?projectid=" + ids_str;
        dsLayerOpen(_uri,'绑定商品','600px','400px');
    }
</script>